package com.gentle.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @author Gentle
 * @date 2019/05/30 : 23:37
 */
@Component
@Configurable
public class RedissonConfig {

    @Autowired
    private RedisConfigInfoProperties redisConfigInfoProperties;

    @Bean
    public RedissonClient redissonClient() {

        Config config = new Config();
        config.useSingleServer()
                .setAddress(redisConfigInfoProperties.getAddress())
                .setConnectionMinimumIdleSize(0)
                .setConnectionPoolSize(3);
        return Redisson.create(config);
    }

}
